package Demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-07-15
 * Time: 18:47
 */
public class Login {
    private String username="yx";
    private String password="123456";

    public void loginInfo(String username,String password) throws UserpwordException,UserNameException{
        if(!this.username.equals(username)){
            throw new UserNameException("用户名:"+username+" 错误");
        }

        if(!this.password.equals(password)){
            throw new UserpwordException("密码:"+password+" 错误");
        }
        System.out.println("登录成功！");
    }

    public static void main(String[] args) {
        Login login=new Login();
        try {
            login.loginInfo("ltt", "123456");
        }catch(UserNameException e) {
            System.out.println("捕获了UserNameException异常");
            e.printStackTrace();
        }catch(UserpwordException e){
            System.out.println("捕获了UserpwordException异常");
            e.printStackTrace();
        }
    }
}
